package com.aaa.system.controller.api;

import com.aaa.entity.CheckItem;
import com.aaa.entity.OperLog;
import com.aaa.system.aop.annotation.Log;
import com.aaa.system.service.ICheckItemService;
import com.aaa.system.service.IOperLogService;
import com.aaa.system.vo.OperLogVo;
import com.aaa.vo.Result;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 响应到前端的controller类
 */
@RestController
@RequestMapping("system/api/checkItem")
public class ApiCheckItemController {

    @Autowired
    private ICheckItemService checkItemService;

    /**
     * 分页动态查询所有检查费用设置
     * @param current  当前页码
     * @param size  每页显示条数
     * @param checkItem 检查费用查询条件对象
     * @return  分页结果
     */
    @PostMapping("selectAll/{current}/{size}")
    public Result<IPage<CheckItem>> selectAll(
            @PathVariable Integer current,
            @PathVariable Integer size,
            @RequestBody CheckItem checkItem
    ){
        Result<IPage<CheckItem>> selectAll = checkItemService.selectAll(current,size,checkItem);
        return selectAll;
    }

    /**
     * 添加/修改检查项目
     * @param checkItem 检查项目信息
     * @return 操作结果信息
     */
    @Log(title = "添加/修改检查项目",business_type = "1")
    @PostMapping("saveOrUpdateInsItem")
    public Result<Boolean> saveOrUpdateInsItem(@RequestBody CheckItem checkItem){
        return checkItemService.saveOrUpdateInsItem(checkItem);
    }

    /**
     * 根据检查项目id删除单个或者多个检查项目
     * @param checkItemIds 检查id数组
     * @return 操作结果信息
     */
    @Log(title = "删除检查项目",business_type = "3")
    @DeleteMapping("deleteCheckItemByIds/{checkItemIds}")
    public Result<Boolean> deleteCheckItemByIds(@PathVariable Long[] checkItemIds){
        return checkItemService.deleteCheckItemByIds(checkItemIds);
    }

    /**
     * 检查管理模块查询所有数据
     * @return 所有数据
     */
    @GetMapping("/selectAllCheckItem")
    public Result<List<CheckItem>> getInfo(){
        return checkItemService.findAll();
    }
}
